package com.deloitte.sapnetweaver.command
{
	import com.adobe.cairngorm.control.CairngormEvent;
	import com.deloitte.sapnetweaver.business.DocumentDetailsDelegate;
	import com.deloitte.sapnetweaver.command.BaseGetDataCommand;
	import com.deloitte.sapnetweaver.events.DocumentDetailsEvent;
	import com.deloitte.sapnetweaver.vo.DocumentDetailVO;
	
	import mx.controls.Alert;
	import mx.rpc.events.ResultEvent;

	public class DeleteDocumentDetailsCommand extends BaseGetDataCommand
	{
		override public  function execute(event:CairngormEvent):void {
			this._event = event;
			new DocumentDetailsDelegate(this).deleteDocumentDetails(DocumentDetailsEvent(event).documentDetailVO);
		}
		public override function result(data:Object):void {
			Alert.show("Document Delete Complete");
			if(_model.commonModel.allDocumentDetails != null){
				var index:int = _model.commonModel.allDocumentDetails.getItemIndex(DocumentDetailsEvent(this._event).documentDetailVO);
				_model.commonModel.allDocumentDetails.removeItemAt(index); 
				_model.commonModel.selectedDocumentDetailVO = null;
			}
		}
		
	}
}